<!-- HTML header for doxygen 1.8.20-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=9"/>
	<meta name="generator" content="Doxygen 1.9.4"/>
	<meta name="viewport" content="width=device-width, initial-scale=1"/>
	<title>Raspberry Pi Pico SDK: include/pico/bootrom.h Source File</title>
	<!-- <link href="tabs.css" rel="stylesheet" type="text/css"/> -->
	<script type="text/javascript" src="jquery.js"></script>
	<script type="text/javascript" src="dynsections.js"></script>
	<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
	<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
	<link href="doxygen.css" rel="stylesheet" type="text/css" />
	<link href="normalise.css" rel="stylesheet" type="text/css"/>
<link href="main.css" rel="stylesheet" type="text/css"/>
<link href="styles.css" rel="stylesheet" type="text/css"/>
</head>
<body>
	<div class="navigation-mobile">
		<div class="logo--mobile">
			<a href="/"><img src="logo-mobile.svg" alt="Raspberry Pi"></a>
		</div>
		<div class="navigation-toggle">
			<span class="line-1"></span>
			<span class="line-2">
				<p>Menu Toggle</p>
			</span>
			<span class="line-3"></span>
		</div>
	</div>
	<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
		<div class="logo">
			<a href="index.html"> <img src="logo.svg" alt="Raspberry Pi"></a>
			<span style="display: inline-block; margin-top: 10px;">
				v2.0.0
			</span>
		</div>
		<div class="navigation-footer">
			<img src="logo-mobile.svg" alt="Raspberry Pi">
			<a href="https://www.raspberrypi.com/" target="_blank">By Raspberry Pi Ltd</a>
		</div>
<!-- 		<div class="search">
			<form>
				<input type="search" name="search" id="search" placeholder="Search">
				<input type="submit" value="Search">
			</form>
		</div> -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('bootrom_8h_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle"><div class="title">bootrom.h</div></div>
</div><!--header-->
<div class="contents">
<a href="bootrom_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span><span class="comment">/*</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno">    2</span><span class="comment"> * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno">    3</span><span class="comment"> *</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno">    4</span><span class="comment"> * SPDX-License-Identifier: BSD-3-Clause</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno">    5</span><span class="comment"> */</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno">    6</span> </div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno">    7</span><span class="preprocessor">#ifndef _PICO_BOOTROM_H</span></div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span><span class="preprocessor">#define _PICO_BOOTROM_H</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span> </div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span><span class="preprocessor">#include &quot;<a class="code" href="pico_8h.html">pico.h</a>&quot;</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span><span class="preprocessor">#include &quot;pico/bootrom_constants.h&quot;</span></div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno">   12</span> </div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno">   20</span><span class="preprocessor">#ifndef __ASSEMBLER__</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno">   21</span><span class="preprocessor">#include &lt;string.h&gt;</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span><span class="preprocessor">#include &quot;pico/bootrom/lock.h&quot;</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span><span class="comment">// ROM FUNCTION SIGNATURES</span></div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno">   24</span> </div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span><span class="preprocessor">#if PICO_RP2040</span></div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno">   26</span><span class="keyword">typedef</span> uint32_t (*rom_popcount32_fn)(uint32_t);</div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno">   27</span><span class="keyword">typedef</span> uint32_t (*rom_reverse32_fn)(uint32_t);</div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno">   28</span><span class="keyword">typedef</span> uint32_t (*rom_clz32_fn)(uint32_t);</div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno">   29</span><span class="keyword">typedef</span> uint32_t (*rom_ctz32_fn)(uint32_t);</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno">   30</span><span class="keyword">typedef</span> uint8_t *(*rom_memset_fn)(uint8_t *, uint8_t, uint32_t);</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno">   31</span><span class="keyword">typedef</span> uint32_t *(*rom_memset4_fn)(uint32_t *, uint8_t, uint32_t);</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno">   32</span><span class="keyword">typedef</span> uint32_t *(*rom_memcpy_fn)(uint8_t *, <span class="keyword">const</span> uint8_t *, uint32_t);</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno">   33</span><span class="keyword">typedef</span> uint32_t *(*rom_memcpy44_fn)(uint32_t *, <span class="keyword">const</span> uint32_t *, uint32_t);</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno">   35</span><span class="keyword">typedef</span> <span class="keywordtype">void</span> __attribute__((noreturn)) (*rom_reset_usb_boot_fn)(uint32_t, uint32_t);</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span><span class="keyword">typedef</span> int (*rom_reboot_fn)(uint32_t flags, uint32_t delay_ms, uint32_t p0, uint32_t p1);</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span><span class="keyword">typedef</span> rom_reset_usb_boot_fn reset_usb_boot_fn; <span class="comment">// kept for backwards compatibility</span></div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno">   38</span><span class="keyword">typedef</span> void (*rom_connect_internal_flash_fn)(void);</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno">   39</span><span class="keyword">typedef</span> void (*rom_flash_exit_xip_fn)(void);</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno">   40</span><span class="keyword">typedef</span> void (*rom_flash_range_erase_fn)(uint32_t, size_t, uint32_t, uint8_t);</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span><span class="keyword">typedef</span> void (*rom_flash_range_program_fn)(uint32_t, <span class="keyword">const</span> uint8_t*, size_t);</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno">   42</span><span class="keyword">typedef</span> void (*rom_flash_flush_cache_fn)(void);</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno">   43</span><span class="keyword">typedef</span> void (*rom_flash_enter_cmd_xip_fn)(void);</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno">   44</span><span class="preprocessor">#if !PICO_RP2040</span></div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno">   45</span><span class="keyword">typedef</span> void (*rom_bootrom_state_reset_fn)(uint32_t flags);</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span><span class="keyword">typedef</span> void (*rom_flash_reset_address_trans_fn)(void);</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno">   47</span><span class="keyword">typedef</span> void (*rom_flash_select_xip_read_mode_fn)(bootrom_xip_mode_t mode, uint8_t clkdiv);</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno">   48</span><span class="keyword">typedef</span> int (*rom_get_sys_info_fn)(uint32_t *out_buffer, uint32_t out_buffer_word_size, uint32_t flags);</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno">   49</span><span class="keyword">typedef</span> int (*rom_get_partition_table_info_fn)(uint32_t *out_buffer, uint32_t out_buffer_word_size, uint32_t partition_and_flags);</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno">   50</span><span class="keyword">typedef</span> int (*rom_explicit_buy_fn)(uint8_t *buffer, uint32_t buffer_size);</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno">   51</span><span class="keyword">typedef</span> <span class="keywordtype">void</span>* (*rom_validate_ns_buffer_fn)(<span class="keyword">const</span> <span class="keywordtype">void</span> *addr, uint32_t size, uint32_t write, uint32_t *ok);</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno">   56</span><span class="keyword">typedef</span> intptr_t (*rom_set_rom_callback_fn)(uint callback_num, bootrom_api_callback_generic_t funcptr);</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno">   57</span><span class="keyword">typedef</span> int (*rom_chain_image_fn)(uint8_t *workarea_base, uint32_t workarea_size, uint32_t window_base, uint32_t window_size);</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno">   58</span><span class="keyword">typedef</span> int (*rom_load_partition_table_fn)(uint8_t *workarea_base, uint32_t workarea_size, <span class="keywordtype">bool</span> force_reload);</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno">   59</span><span class="keyword">typedef</span> int (*rom_pick_ab_partition_fn)(uint8_t *workarea_base, uint32_t workarea_size, uint partition_a_num, uint32_t flash_update_boot_window_base);</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno">   60</span><span class="keyword">typedef</span> int (*rom_get_b_partition_fn)(uint pi_a);</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno">   61</span><span class="keyword">typedef</span> int (*rom_get_uf2_target_partition_fn)(uint8_t *workarea_base, uint32_t workarea_size, uint32_t family_id, <a class="code hl_struct" href="structresident__partition__t.html">resident_partition_t</a> *partition_out);</div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span><span class="keyword">typedef</span> int (*rom_func_otp_access_fn)(uint8_t *buf, uint32_t buf_len, <a class="code hl_struct" href="structotp__cmd.html">otp_cmd_t</a> cmd);</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span><span class="comment">// Apply the address translation currently specified in QMI_ATRANSx (&quot;rolling window&quot; hardware</span></div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span><span class="comment">// translation). Need to take care using this on the boot path, as the QMI may not yet have been</span></div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno">   65</span><span class="comment">// set up, but this should be suitable for translating system bus addresses into flash storage</span></div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno">   66</span><span class="comment">// addresses in user callbacks. Returns all-ones for an invalid address, which is also an invalid</span></div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno">   67</span><span class="comment">// flash storage address, so invalidity is propagated.</span></div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno">   68</span><span class="keyword">typedef</span> intptr_t (*rom_flash_runtime_to_storage_addr_fn)(uintptr_t flash_runtime_addr);</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno">   69</span> </div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno">   70</span><span class="comment">// Perform the specified erase/program/read operation, translating addresses according to</span></div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno">   71</span><span class="comment">// QMI_ATRANSx if necessary, and checking flash permissions based on the resident partition table</span></div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno">   72</span><span class="comment">// and the specified effective security level. `addr` may be either a flash runtime address or a</span></div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno">   73</span><span class="comment">// flash storage address, depending on the ASPACE given in `flags`.</span></div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno">   74</span><span class="comment">//</span></div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno">   75</span><span class="comment">// NOTE: This function does not validate the buffer for NS access. This must be validated before</span></div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno">   76</span><span class="comment">// calling if the caller is reachable from a Secure Gateway.</span></div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno">   77</span><span class="keyword">typedef</span> int (*rom_flash_op_fn)(<a class="code hl_struct" href="structcflash__flags.html">cflash_flags_t</a> flags, uintptr_t addr, uint32_t size_bytes, uint8_t *buf);</div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno">   78</span> </div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno">   79</span><span class="preprocessor">#ifndef __riscv</span></div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno">   80</span><span class="keyword">typedef</span> int (*rom_set_ns_api_permission_fn)(uint ns_api_num, <span class="keywordtype">bool</span> allowed);</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span><span class="keyword">typedef</span> int (*rom_func_secure_call)(uintptr_t a0, ...);</div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno">   95</span> </div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno">   96</span><span class="preprocessor">#ifdef __riscv</span></div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno">   97</span><span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno">   98</span>    uint32_t *base;</div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno">   99</span>    uint32_t size;</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno">  100</span>} bootrom_stack_t;</div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno">  101</span><span class="comment">// passed in, and out.</span></div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno">  102</span><span class="keyword">typedef</span> int (*rom_set_bootrom_stack_fn)(bootrom_stack_t *stack);</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno">  103</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno">  104</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno">  105</span> </div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno">  106</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno">  107</span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno">  108</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno">  109</span> </div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"><a class="line" href="group__pico__bootrom.html#ga2b6dcf9d9c60d54a222f7c259c76b4b4">  119</a></span><span class="keyword">static</span> <span class="keyword">inline</span> uint32_t <a class="code hl_function" href="group__pico__bootrom.html#ga2b6dcf9d9c60d54a222f7c259c76b4b4">rom_table_code</a>(uint8_t c1, uint8_t c2) {</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno">  120</span>    <span class="keywordflow">return</span> <a class="code hl_define" href="group__pico__bootrom.html#ga5b3c93cbab0054e9938f2aca7261a73e">ROM_TABLE_CODE</a>((uint32_t) c1, (uint32_t) c2);</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno">  121</span>}</div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno">  122</span> </div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno">  129</span><span class="keywordtype">void</span> *<a class="code hl_function" href="group__pico__bootrom.html#gaaaf61234f389da6444b6479f29616d7d">rom_func_lookup</a>(uint32_t code);</div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno">  130</span> </div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno">  137</span><span class="keywordtype">void</span> *<a class="code hl_function" href="group__pico__bootrom.html#gad3e66e7bcbf0448a0a63cf37dfb4b53c">rom_data_lookup</a>(uint32_t code);</div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno">  138</span> </div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno">  150</span><span class="keywordtype">bool</span> <a class="code hl_function" href="group__pico__bootrom.html#ga31965209f0ddaeaecaeb3c516abda04d">rom_funcs_lookup</a>(uint32_t *table, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> count);</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno">  151</span> </div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno">  152</span><span class="comment">// Bootrom function: rom_table_lookup</span></div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno">  153</span><span class="comment">// Returns the 32 bit pointer into the ROM if found or NULL otherwise.</span></div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno">  154</span><span class="preprocessor">#if PICO_RP2040</span></div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno">  155</span><span class="keyword">typedef</span> <span class="keywordtype">void</span> *(*rom_table_lookup_fn)(uint16_t *table, uint32_t code);</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno">  156</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno">  157</span><span class="keyword">typedef</span> <span class="keywordtype">void</span> *(*rom_table_lookup_fn)(uint32_t code, uint32_t mask);</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno">  158</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno">  159</span> </div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno">  160</span><span class="preprocessor">#if PICO_C_COMPILER_IS_GNU &amp;&amp; (__GNUC__ &gt;= 12)</span></div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno">  161</span><span class="comment">// Convert a 16 bit pointer stored at the given rom address into a 32 bit pointer</span></div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno">  162</span><a class="code hl_define" href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a> <span class="keyword">static</span> <span class="keywordtype">void</span> *rom_hword_as_ptr(uint16_t rom_address) {</div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno">  163</span><span class="preprocessor">#pragma GCC diagnostic push</span></div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno">  164</span><span class="preprocessor">#pragma GCC diagnostic ignored &quot;-Warray-bounds&quot;</span></div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno">  165</span>    <span class="keywordflow">return</span> (<span class="keywordtype">void</span> *)(uintptr_t)*(uint16_t *)(uintptr_t)rom_address;</div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno">  166</span><span class="preprocessor">#pragma GCC diagnostic pop</span></div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno">  167</span>}</div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno">  168</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno">  169</span><span class="comment">// Convert a 16 bit pointer stored at the given rom address into a 32 bit pointer</span></div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno">  170</span><span class="preprocessor">#define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)(uintptr_t)(rom_address))</span></div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno">  171</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno">  172</span> </div>
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno">  173</span><span class="preprocessor">#ifdef __riscv</span></div>
<div class="line"><a id="l00174" name="l00174"></a><span class="lineno">  174</span><span class="keyword">static</span> <a class="code hl_define" href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a> <span class="keywordtype">bool</span> rom_size_is_64k(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno">  175</span><span class="preprocessor">#ifdef RASPBERRYPI_AMETHYST_FPGA</span></div>
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno">  176</span>    <span class="comment">// Detect ROM size by testing for bus fault at +32k</span></div>
<div class="line"><a id="l00177" name="l00177"></a><span class="lineno">  177</span>    uint result;</div>
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno">  178</span>    pico_default_asm_volatile (</div>
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno">  179</span>        <span class="stringliteral">&quot;li %0, 0\n&quot;</span></div>
<div class="line"><a id="l00180" name="l00180"></a><span class="lineno">  180</span>        <span class="comment">// Save and disable IRQs before touching trap vector</span></div>
<div class="line"><a id="l00181" name="l00181"></a><span class="lineno">  181</span>        <span class="stringliteral">&quot;csrr t2, mstatus\n&quot;</span></div>
<div class="line"><a id="l00182" name="l00182"></a><span class="lineno">  182</span>        <span class="stringliteral">&quot;csrci mstatus, 0x8\n&quot;</span></div>
<div class="line"><a id="l00183" name="l00183"></a><span class="lineno">  183</span>        <span class="comment">// Set up trap vector to skip the instruction which sets the %0 flag</span></div>
<div class="line"><a id="l00184" name="l00184"></a><span class="lineno">  184</span>        <span class="stringliteral">&quot;la t0, 1f\n&quot;</span></div>
<div class="line"><a id="l00185" name="l00185"></a><span class="lineno">  185</span>        <span class="stringliteral">&quot;csrrw t0, mtvec, t0\n&quot;</span></div>
<div class="line"><a id="l00186" name="l00186"></a><span class="lineno">  186</span>        <span class="comment">// This load will fault if the bootrom is no larger than 32k:</span></div>
<div class="line"><a id="l00187" name="l00187"></a><span class="lineno">  187</span>        <span class="stringliteral">&quot;li t1, 32 * 1024\n&quot;</span></div>
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno">  188</span>        <span class="stringliteral">&quot;lw t1, (t1)\n&quot;</span></div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno">  189</span>        <span class="comment">// No fault, so set return to true</span></div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno">  190</span>        <span class="stringliteral">&quot;li %0, 1\n&quot;</span></div>
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno">  191</span>        <span class="stringliteral">&quot;.p2align 2\n&quot;</span></div>
<div class="line"><a id="l00192" name="l00192"></a><span class="lineno">  192</span>        <span class="comment">// Always end up back here, restore the trap table</span></div>
<div class="line"><a id="l00193" name="l00193"></a><span class="lineno">  193</span>        <span class="stringliteral">&quot;1:\n&quot;</span></div>
<div class="line"><a id="l00194" name="l00194"></a><span class="lineno">  194</span>        <span class="stringliteral">&quot;csrw mtvec, t0\n&quot;</span></div>
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno">  195</span>        <span class="comment">// Now safe to restore interrupts</span></div>
<div class="line"><a id="l00196" name="l00196"></a><span class="lineno">  196</span>        <span class="stringliteral">&quot;csrw mstatus, t2\n&quot;</span></div>
<div class="line"><a id="l00197" name="l00197"></a><span class="lineno">  197</span>        : <span class="stringliteral">&quot;=r&quot;</span> (result)</div>
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno">  198</span>        :</div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno">  199</span>        : <span class="stringliteral">&quot;t0&quot;</span>, <span class="stringliteral">&quot;t1&quot;</span>, <span class="stringliteral">&quot;t2&quot;</span></div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno">  200</span>    );</div>
<div class="line"><a id="l00201" name="l00201"></a><span class="lineno">  201</span>    <span class="keywordflow">return</span> result;</div>
<div class="line"><a id="l00202" name="l00202"></a><span class="lineno">  202</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00203" name="l00203"></a><span class="lineno">  203</span>    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a id="l00204" name="l00204"></a><span class="lineno">  204</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00205" name="l00205"></a><span class="lineno">  205</span>}</div>
<div class="line"><a id="l00206" name="l00206"></a><span class="lineno">  206</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00207" name="l00207"></a><span class="lineno">  207</span> </div>
<div class="line"><a id="l00214" name="l00214"></a><span class="lineno">  214</span><span class="preprocessor">#pragma GCC diagnostic push</span></div>
<div class="line"><a id="l00215" name="l00215"></a><span class="lineno">  215</span><span class="comment">// diagnostic: GCC thinks near-zero value is a null pointer member access, but it&#39;s not</span></div>
<div class="line"><a id="l00216" name="l00216"></a><span class="lineno">  216</span><span class="preprocessor">#pragma GCC diagnostic ignored &quot;-Warray-bounds&quot;</span></div>
<div class="line"><a id="l00217" name="l00217"></a><span class="lineno"><a class="line" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">  217</a></span><span class="keyword">static</span> <a class="code hl_define" href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a> <span class="keywordtype">void</span> *<a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(uint32_t code) {</div>
<div class="line"><a id="l00218" name="l00218"></a><span class="lineno">  218</span><span class="preprocessor">#if PICO_RP2040</span></div>
<div class="line"><a id="l00219" name="l00219"></a><span class="lineno">  219</span>    rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(BOOTROM_TABLE_LOOKUP_OFFSET);</div>
<div class="line"><a id="l00220" name="l00220"></a><span class="lineno">  220</span>    uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(BOOTROM_FUNC_TABLE_OFFSET);</div>
<div class="line"><a id="l00221" name="l00221"></a><span class="lineno">  221</span>    <span class="keywordflow">return</span> rom_table_lookup(func_table, code);</div>
<div class="line"><a id="l00222" name="l00222"></a><span class="lineno">  222</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00223" name="l00223"></a><span class="lineno">  223</span><span class="preprocessor">#ifdef __riscv</span></div>
<div class="line"><a id="l00224" name="l00224"></a><span class="lineno">  224</span>    uint32_t rom_offset_adjust = rom_size_is_64k() ? 32 * 1024 : 0;</div>
<div class="line"><a id="l00225" name="l00225"></a><span class="lineno">  225</span>    <span class="comment">// on RISC-V the code (a jmp) is actually embedded in the table</span></div>
<div class="line"><a id="l00226" name="l00226"></a><span class="lineno">  226</span>    rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) (uintptr_t)*(uint16_t*)(BOOTROM_TABLE_LOOKUP_ENTRY_OFFSET + rom_offset_adjust);</div>
<div class="line"><a id="l00227" name="l00227"></a><span class="lineno">  227</span>    <span class="keywordflow">return</span> rom_table_lookup(code, RT_FLAG_FUNC_RISCV);</div>
<div class="line"><a id="l00228" name="l00228"></a><span class="lineno">  228</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00229" name="l00229"></a><span class="lineno">  229</span>    <span class="comment">// on ARM the function pointer is stored in the table, so we dereference it</span></div>
<div class="line"><a id="l00230" name="l00230"></a><span class="lineno">  230</span>    <span class="comment">// via lookup() rather than lookup_entry()</span></div>
<div class="line"><a id="l00231" name="l00231"></a><span class="lineno">  231</span>    rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) (uintptr_t)*(uint16_t*)(BOOTROM_TABLE_LOOKUP_OFFSET);</div>
<div class="line"><a id="l00232" name="l00232"></a><span class="lineno">  232</span>    <span class="keywordflow">if</span> (<a class="code hl_function" href="group__pico__platform.html#ga66edd7569f5a42b0a2da43a5926cf064">pico_processor_state_is_nonsecure</a>()) {</div>
<div class="line"><a id="l00233" name="l00233"></a><span class="lineno">  233</span>        <span class="keywordflow">return</span> rom_table_lookup(code, RT_FLAG_FUNC_ARM_NONSEC);</div>
<div class="line"><a id="l00234" name="l00234"></a><span class="lineno">  234</span>    } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00235" name="l00235"></a><span class="lineno">  235</span>        <span class="keywordflow">return</span> rom_table_lookup(code, RT_FLAG_FUNC_ARM_SEC);</div>
<div class="line"><a id="l00236" name="l00236"></a><span class="lineno">  236</span>    }</div>
<div class="line"><a id="l00237" name="l00237"></a><span class="lineno">  237</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00238" name="l00238"></a><span class="lineno">  238</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00239" name="l00239"></a><span class="lineno">  239</span>}</div>
<div class="line"><a id="l00240" name="l00240"></a><span class="lineno">  240</span><span class="preprocessor">#pragma GCC diagnostic pop</span></div>
<div class="line"><a id="l00241" name="l00241"></a><span class="lineno">  241</span> </div>
<div class="line"><a id="l00259" name="l00259"></a><span class="lineno">  259</span><span class="keywordtype">void</span> __attribute__((noreturn)) <a class="code hl_function" href="group__pico__bootrom.html#ga1bbe1c1df02daaa7b68a0c95fb9dc545">rom_reset_usb_boot</a>(uint32_t usb_activity_gpio_pin_mask, uint32_t disable_interface_mask);</div>
<div class="line"><a id="l00260" name="l00260"></a><span class="lineno">  260</span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> __attribute__((noreturn)) reset_usb_boot(uint32_t usb_activity_gpio_pin_mask, uint32_t disable_interface_mask) {</div>
<div class="line"><a id="l00261" name="l00261"></a><span class="lineno">  261</span>    <a class="code hl_function" href="group__pico__bootrom.html#ga1bbe1c1df02daaa7b68a0c95fb9dc545">rom_reset_usb_boot</a>(usb_activity_gpio_pin_mask, disable_interface_mask);</div>
<div class="line"><a id="l00262" name="l00262"></a><span class="lineno">  262</span>}</div>
<div class="line"><a id="l00263" name="l00263"></a><span class="lineno">  263</span> </div>
<div class="line"><a id="l00276" name="l00276"></a><span class="lineno"><a class="line" href="group__pico__bootrom.html#gaa089fab5e976fea3fd88fecb44863ffc">  276</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__pico__bootrom.html#gaa089fab5e976fea3fd88fecb44863ffc">rom_connect_internal_flash</a>() {</div>
<div class="line"><a id="l00277" name="l00277"></a><span class="lineno">  277</span>    rom_connect_internal_flash_fn func = (rom_connect_internal_flash_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_CONNECT_INTERNAL_FLASH);</div>
<div class="line"><a id="l00278" name="l00278"></a><span class="lineno">  278</span>    func();</div>
<div class="line"><a id="l00279" name="l00279"></a><span class="lineno">  279</span>}</div>
<div class="line"><a id="l00280" name="l00280"></a><span class="lineno">  280</span> </div>
<div class="line"><a id="l00307" name="l00307"></a><span class="lineno"><a class="line" href="group__pico__bootrom.html#ga472decf755ee1f64afdf14a90e6c8807">  307</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__pico__bootrom.html#ga472decf755ee1f64afdf14a90e6c8807">rom_flash_exit_xip</a>() {</div>
<div class="line"><a id="l00308" name="l00308"></a><span class="lineno">  308</span>    rom_flash_exit_xip_fn func = (rom_flash_exit_xip_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_FLASH_EXIT_XIP);</div>
<div class="line"><a id="l00309" name="l00309"></a><span class="lineno">  309</span>    func();</div>
<div class="line"><a id="l00310" name="l00310"></a><span class="lineno">  310</span>}</div>
<div class="line"><a id="l00311" name="l00311"></a><span class="lineno">  311</span> </div>
<div class="line"><a id="l00343" name="l00343"></a><span class="lineno"><a class="line" href="group__pico__bootrom.html#gad2a854a04f7007e9e5efa67fe8887cd7">  343</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__pico__bootrom.html#gad2a854a04f7007e9e5efa67fe8887cd7">rom_flash_range_erase</a>(uint32_t addr, <span class="keywordtype">size_t</span> count, uint32_t block_size, uint8_t block_cmd) {</div>
<div class="line"><a id="l00344" name="l00344"></a><span class="lineno">  344</span>    rom_flash_range_erase_fn func = (rom_flash_range_erase_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_FLASH_RANGE_ERASE);</div>
<div class="line"><a id="l00345" name="l00345"></a><span class="lineno">  345</span>    func(addr, count, block_size, block_cmd);</div>
<div class="line"><a id="l00346" name="l00346"></a><span class="lineno">  346</span>}</div>
<div class="line"><a id="l00347" name="l00347"></a><span class="lineno">  347</span> </div>
<div class="line"><a id="l00368" name="l00368"></a><span class="lineno"><a class="line" href="group__pico__bootrom.html#ga7fd2af8eea3dbd7bc76ed3306186ccef">  368</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__pico__bootrom.html#ga7fd2af8eea3dbd7bc76ed3306186ccef">rom_flash_range_program</a>(uint32_t addr, <span class="keyword">const</span> uint8_t *data, <span class="keywordtype">size_t</span> count) {</div>
<div class="line"><a id="l00369" name="l00369"></a><span class="lineno">  369</span>    rom_flash_range_program_fn func = (rom_flash_range_program_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_FLASH_RANGE_PROGRAM);</div>
<div class="line"><a id="l00370" name="l00370"></a><span class="lineno">  370</span>    func(addr, data, count);</div>
<div class="line"><a id="l00371" name="l00371"></a><span class="lineno">  371</span>}</div>
<div class="line"><a id="l00372" name="l00372"></a><span class="lineno">  372</span> </div>
<div class="line"><a id="l00390" name="l00390"></a><span class="lineno"><a class="line" href="group__pico__bootrom.html#gacd6b37e87ff97264edba6c6349e52f72">  390</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__pico__bootrom.html#gacd6b37e87ff97264edba6c6349e52f72">rom_flash_flush_cache</a>() {</div>
<div class="line"><a id="l00391" name="l00391"></a><span class="lineno">  391</span>    rom_flash_flush_cache_fn func = (rom_flash_flush_cache_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_FLASH_FLUSH_CACHE);</div>
<div class="line"><a id="l00392" name="l00392"></a><span class="lineno">  392</span>    func();</div>
<div class="line"><a id="l00393" name="l00393"></a><span class="lineno">  393</span>}</div>
<div class="line"><a id="l00394" name="l00394"></a><span class="lineno">  394</span> </div>
<div class="line"><a id="l00406" name="l00406"></a><span class="lineno"><a class="line" href="group__pico__bootrom.html#gae2af7b462bd0a7e9d0fc0a5fc1ce909e">  406</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__pico__bootrom.html#gae2af7b462bd0a7e9d0fc0a5fc1ce909e">rom_flash_enter_cmd_xip</a>() {</div>
<div class="line"><a id="l00407" name="l00407"></a><span class="lineno">  407</span>    rom_flash_enter_cmd_xip_fn func = (rom_flash_enter_cmd_xip_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_FLASH_ENTER_CMD_XIP);</div>
<div class="line"><a id="l00408" name="l00408"></a><span class="lineno">  408</span>    func();</div>
<div class="line"><a id="l00409" name="l00409"></a><span class="lineno">  409</span>}</div>
<div class="line"><a id="l00410" name="l00410"></a><span class="lineno">  410</span> </div>
<div class="line"><a id="l00411" name="l00411"></a><span class="lineno">  411</span><span class="preprocessor">#if !PICO_RP2040</span></div>
<div class="line"><a id="l00412" name="l00412"></a><span class="lineno">  412</span><span class="preprocessor">#ifdef __riscv</span></div>
<div class="line"><a id="l00429" name="l00429"></a><span class="lineno">  429</span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> rom_set_bootrom_stack(bootrom_stack_t *stack) {</div>
<div class="line"><a id="l00430" name="l00430"></a><span class="lineno">  430</span>    rom_set_bootrom_stack_fn func = (rom_set_bootrom_stack_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_SET_BOOTROM_STACK);</div>
<div class="line"><a id="l00431" name="l00431"></a><span class="lineno">  431</span>    <span class="keywordflow">return</span> func(stack);</div>
<div class="line"><a id="l00432" name="l00432"></a><span class="lineno">  432</span>}</div>
<div class="line"><a id="l00433" name="l00433"></a><span class="lineno">  433</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00434" name="l00434"></a><span class="lineno">  434</span> </div>
<div class="line"><a id="l00481" name="l00481"></a><span class="lineno">  481</span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> rom_reboot(uint32_t flags, uint32_t delay_ms, uint32_t p0, uint32_t p1) {</div>
<div class="line"><a id="l00482" name="l00482"></a><span class="lineno">  482</span>    rom_reboot_fn func = (rom_reboot_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_REBOOT);</div>
<div class="line"><a id="l00483" name="l00483"></a><span class="lineno">  483</span>    <span class="keywordflow">return</span> func(flags, delay_ms, p0, p1);</div>
<div class="line"><a id="l00484" name="l00484"></a><span class="lineno">  484</span>}</div>
<div class="line"><a id="l00485" name="l00485"></a><span class="lineno">  485</span> </div>
<div class="line"><a id="l00486" name="l00486"></a><span class="lineno">  486</span><span class="keywordtype">bool</span> rom_get_boot_random(uint32_t out[4]);</div>
<div class="line"><a id="l00487" name="l00487"></a><span class="lineno">  487</span> </div>
<div class="line"><a id="l00512" name="l00512"></a><span class="lineno">  512</span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> rom_bootrom_state_reset(uint32_t flags) {</div>
<div class="line"><a id="l00513" name="l00513"></a><span class="lineno">  513</span>    rom_bootrom_state_reset_fn func = (rom_bootrom_state_reset_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_BOOTROM_STATE_RESET);</div>
<div class="line"><a id="l00514" name="l00514"></a><span class="lineno">  514</span>    <span class="keywordflow">return</span> func(flags);</div>
<div class="line"><a id="l00515" name="l00515"></a><span class="lineno">  515</span>}</div>
<div class="line"><a id="l00516" name="l00516"></a><span class="lineno">  516</span> </div>
<div class="line"><a id="l00525" name="l00525"></a><span class="lineno">  525</span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> rom_flash_reset_address_trans(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00526" name="l00526"></a><span class="lineno">  526</span>    rom_flash_reset_address_trans_fn func = (rom_flash_reset_address_trans_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_FLASH_RESET_ADDRESS_TRANS);</div>
<div class="line"><a id="l00527" name="l00527"></a><span class="lineno">  527</span>    func();</div>
<div class="line"><a id="l00528" name="l00528"></a><span class="lineno">  528</span>}</div>
<div class="line"><a id="l00529" name="l00529"></a><span class="lineno">  529</span> </div>
<div class="line"><a id="l00540" name="l00540"></a><span class="lineno">  540</span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> rom_flash_select_xip_read_mode(bootrom_xip_mode_t mode, uint8_t clkdiv) {</div>
<div class="line"><a id="l00541" name="l00541"></a><span class="lineno">  541</span>    rom_flash_select_xip_read_mode_fn func = (rom_flash_select_xip_read_mode_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_FLASH_SELECT_XIP_READ_MODE);</div>
<div class="line"><a id="l00542" name="l00542"></a><span class="lineno">  542</span>    func(mode, clkdiv);</div>
<div class="line"><a id="l00543" name="l00543"></a><span class="lineno">  543</span>}</div>
<div class="line"><a id="l00544" name="l00544"></a><span class="lineno">  544</span> </div>
<div class="line"><a id="l00584" name="l00584"></a><span class="lineno">  584</span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> rom_flash_op(<a class="code hl_struct" href="structcflash__flags.html">cflash_flags_t</a> flags, uintptr_t addr, uint32_t size_bytes, uint8_t *buf) {</div>
<div class="line"><a id="l00585" name="l00585"></a><span class="lineno">  585</span>    rom_flash_op_fn func = (rom_flash_op_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_FLASH_OP);</div>
<div class="line"><a id="l00586" name="l00586"></a><span class="lineno">  586</span>    <span class="keywordflow">if</span> (!bootrom_try_acquire_lock(BOOTROM_LOCK_FLASH_OP))</div>
<div class="line"><a id="l00587" name="l00587"></a><span class="lineno">  587</span>        <span class="keywordflow">return</span> BOOTROM_ERROR_LOCK_REQUIRED;</div>
<div class="line"><a id="l00588" name="l00588"></a><span class="lineno">  588</span>    <span class="keywordtype">int</span> rc = func(flags, addr, size_bytes, buf);</div>
<div class="line"><a id="l00589" name="l00589"></a><span class="lineno">  589</span>    bootrom_release_lock(BOOTROM_LOCK_FLASH_OP);</div>
<div class="line"><a id="l00590" name="l00590"></a><span class="lineno">  590</span>    <span class="keywordflow">return</span> rc;</div>
<div class="line"><a id="l00591" name="l00591"></a><span class="lineno">  591</span>}</div>
<div class="line"><a id="l00592" name="l00592"></a><span class="lineno">  592</span> </div>
<div class="line"><a id="l00617" name="l00617"></a><span class="lineno">  617</span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> rom_func_otp_access(uint8_t *buf, uint32_t buf_len, <a class="code hl_struct" href="structotp__cmd.html">otp_cmd_t</a> cmd) {</div>
<div class="line"><a id="l00618" name="l00618"></a><span class="lineno">  618</span>    rom_func_otp_access_fn func = (rom_func_otp_access_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_OTP_ACCESS);</div>
<div class="line"><a id="l00619" name="l00619"></a><span class="lineno">  619</span>    <span class="keywordflow">if</span> (!bootrom_try_acquire_lock(BOOTROM_LOCK_OTP))</div>
<div class="line"><a id="l00620" name="l00620"></a><span class="lineno">  620</span>        <span class="keywordflow">return</span> BOOTROM_ERROR_LOCK_REQUIRED;</div>
<div class="line"><a id="l00621" name="l00621"></a><span class="lineno">  621</span>    <span class="keywordtype">int</span> rc = func(buf, buf_len, cmd);</div>
<div class="line"><a id="l00622" name="l00622"></a><span class="lineno">  622</span>    bootrom_release_lock(BOOTROM_LOCK_OTP);</div>
<div class="line"><a id="l00623" name="l00623"></a><span class="lineno">  623</span>    <span class="keywordflow">return</span> rc;</div>
<div class="line"><a id="l00624" name="l00624"></a><span class="lineno">  624</span>}</div>
<div class="line"><a id="l00625" name="l00625"></a><span class="lineno">  625</span> </div>
<div class="line"><a id="l00654" name="l00654"></a><span class="lineno">  654</span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> rom_get_partition_table_info(uint32_t *out_buffer, uint32_t out_buffer_word_size, uint32_t partition_and_flags) {</div>
<div class="line"><a id="l00655" name="l00655"></a><span class="lineno">  655</span>    rom_get_partition_table_info_fn func = (rom_get_partition_table_info_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_GET_PARTITION_TABLE_INFO);</div>
<div class="line"><a id="l00656" name="l00656"></a><span class="lineno">  656</span>    <span class="keywordflow">if</span> (!bootrom_try_acquire_lock(BOOTROM_LOCK_SHA_256))</div>
<div class="line"><a id="l00657" name="l00657"></a><span class="lineno">  657</span>        <span class="keywordflow">return</span> BOOTROM_ERROR_LOCK_REQUIRED;</div>
<div class="line"><a id="l00658" name="l00658"></a><span class="lineno">  658</span>    <span class="keywordtype">int</span> rc = func(out_buffer, out_buffer_word_size, partition_and_flags);</div>
<div class="line"><a id="l00659" name="l00659"></a><span class="lineno">  659</span>    bootrom_release_lock(BOOTROM_LOCK_SHA_256);</div>
<div class="line"><a id="l00660" name="l00660"></a><span class="lineno">  660</span>    <span class="keywordflow">return</span> rc;</div>
<div class="line"><a id="l00661" name="l00661"></a><span class="lineno">  661</span>}</div>
<div class="line"><a id="l00662" name="l00662"></a><span class="lineno">  662</span> </div>
<div class="line"><a id="l00663" name="l00663"></a><span class="lineno">  663</span><span class="comment">// todo SECURE only</span></div>
<div class="line"><a id="l00679" name="l00679"></a><span class="lineno">  679</span><span class="comment"></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> rom_load_partition_table(uint8_t *workarea_base, uint32_t workarea_size, <span class="keywordtype">bool</span> force_reload) {</div>
<div class="line"><a id="l00680" name="l00680"></a><span class="lineno">  680</span>    rom_load_partition_table_fn func = (rom_load_partition_table_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_LOAD_PARTITION_TABLE);</div>
<div class="line"><a id="l00681" name="l00681"></a><span class="lineno">  681</span>    <span class="keywordflow">if</span> (!bootrom_try_acquire_lock(BOOTROM_LOCK_SHA_256))</div>
<div class="line"><a id="l00682" name="l00682"></a><span class="lineno">  682</span>        <span class="keywordflow">return</span> BOOTROM_ERROR_LOCK_REQUIRED;</div>
<div class="line"><a id="l00683" name="l00683"></a><span class="lineno">  683</span>    <span class="keywordtype">int</span> rc = func(workarea_base, workarea_size, force_reload);</div>
<div class="line"><a id="l00684" name="l00684"></a><span class="lineno">  684</span>    bootrom_release_lock(BOOTROM_LOCK_SHA_256);</div>
<div class="line"><a id="l00685" name="l00685"></a><span class="lineno">  685</span>    <span class="keywordflow">return</span> rc;</div>
<div class="line"><a id="l00686" name="l00686"></a><span class="lineno">  686</span>}</div>
<div class="line"><a id="l00687" name="l00687"></a><span class="lineno">  687</span> </div>
<div class="line"><a id="l00688" name="l00688"></a><span class="lineno">  688</span><span class="comment">// todo SECURE only</span></div>
<div class="line"><a id="l00711" name="l00711"></a><span class="lineno">  711</span><span class="comment"></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> rom_pick_ab_partition(uint8_t *workarea_base, uint32_t workarea_size, uint partition_a_num, uint32_t flash_update_boot_window_base) {</div>
<div class="line"><a id="l00712" name="l00712"></a><span class="lineno">  712</span>    rom_pick_ab_partition_fn func = (rom_pick_ab_partition_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_PICK_AB_PARTITION);</div>
<div class="line"><a id="l00713" name="l00713"></a><span class="lineno">  713</span>    <span class="keywordflow">if</span> (!bootrom_try_acquire_lock(BOOTROM_LOCK_SHA_256))</div>
<div class="line"><a id="l00714" name="l00714"></a><span class="lineno">  714</span>        <span class="keywordflow">return</span> BOOTROM_ERROR_LOCK_REQUIRED;</div>
<div class="line"><a id="l00715" name="l00715"></a><span class="lineno">  715</span>    <span class="keywordtype">int</span> rc = func(workarea_base, workarea_size, partition_a_num, flash_update_boot_window_base);</div>
<div class="line"><a id="l00716" name="l00716"></a><span class="lineno">  716</span>    bootrom_release_lock(BOOTROM_LOCK_SHA_256);</div>
<div class="line"><a id="l00717" name="l00717"></a><span class="lineno">  717</span>    <span class="keywordflow">return</span> rc;</div>
<div class="line"><a id="l00718" name="l00718"></a><span class="lineno">  718</span>}</div>
<div class="line"><a id="l00719" name="l00719"></a><span class="lineno">  719</span> </div>
<div class="line"><a id="l00729" name="l00729"></a><span class="lineno">  729</span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> rom_get_b_partition(uint pi_a) {</div>
<div class="line"><a id="l00730" name="l00730"></a><span class="lineno">  730</span>    rom_get_b_partition_fn func = (rom_get_b_partition_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_GET_B_PARTITION);</div>
<div class="line"><a id="l00731" name="l00731"></a><span class="lineno">  731</span>    <span class="keywordflow">return</span> func(pi_a);</div>
<div class="line"><a id="l00732" name="l00732"></a><span class="lineno">  732</span>}</div>
<div class="line"><a id="l00733" name="l00733"></a><span class="lineno">  733</span> </div>
<div class="line"><a id="l00734" name="l00734"></a><span class="lineno">  734</span><span class="comment">// todo SECURE only</span></div>
<div class="line"><a id="l00755" name="l00755"></a><span class="lineno">  755</span><span class="comment"></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> rom_get_uf2_target_partition(uint8_t *workarea_base, uint32_t workarea_size, uint32_t family_id, <a class="code hl_struct" href="structresident__partition__t.html">resident_partition_t</a> *partition_out) {</div>
<div class="line"><a id="l00756" name="l00756"></a><span class="lineno">  756</span>    rom_get_uf2_target_partition_fn func = (rom_get_uf2_target_partition_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_GET_UF2_TARGET_PARTITION);</div>
<div class="line"><a id="l00757" name="l00757"></a><span class="lineno">  757</span>    <span class="keywordflow">if</span> (!bootrom_try_acquire_lock(BOOTROM_LOCK_SHA_256))</div>
<div class="line"><a id="l00758" name="l00758"></a><span class="lineno">  758</span>        <span class="keywordflow">return</span> BOOTROM_ERROR_LOCK_REQUIRED;</div>
<div class="line"><a id="l00759" name="l00759"></a><span class="lineno">  759</span>    <span class="keywordtype">int</span> rc = func(workarea_base, workarea_size, family_id, partition_out);</div>
<div class="line"><a id="l00760" name="l00760"></a><span class="lineno">  760</span>    bootrom_release_lock(BOOTROM_LOCK_SHA_256);</div>
<div class="line"><a id="l00761" name="l00761"></a><span class="lineno">  761</span>    <span class="keywordflow">return</span> rc;</div>
<div class="line"><a id="l00762" name="l00762"></a><span class="lineno">  762</span>}</div>
<div class="line"><a id="l00763" name="l00763"></a><span class="lineno">  763</span> </div>
<div class="line"><a id="l00776" name="l00776"></a><span class="lineno">  776</span><span class="keyword">static</span> <span class="keyword">inline</span> intptr_t rom_flash_runtime_to_storage_addr(uintptr_t flash_runtime_addr) {</div>
<div class="line"><a id="l00777" name="l00777"></a><span class="lineno">  777</span>    rom_flash_runtime_to_storage_addr_fn func = (rom_flash_runtime_to_storage_addr_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_FLASH_RUNTIME_TO_STORAGE_ADDR);</div>
<div class="line"><a id="l00778" name="l00778"></a><span class="lineno">  778</span>    <span class="keywordflow">return</span> func(flash_runtime_addr);</div>
<div class="line"><a id="l00779" name="l00779"></a><span class="lineno">  779</span>}</div>
<div class="line"><a id="l00780" name="l00780"></a><span class="lineno">  780</span> </div>
<div class="line"><a id="l00781" name="l00781"></a><span class="lineno">  781</span><span class="comment">// todo SECURE only</span></div>
<div class="line"><a id="l00809" name="l00809"></a><span class="lineno">  809</span><span class="comment"></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> rom_chain_image(uint8_t *workarea_base, uint32_t workarea_size, uint32_t region_base, uint32_t region_size) {</div>
<div class="line"><a id="l00810" name="l00810"></a><span class="lineno">  810</span>    rom_chain_image_fn func = (rom_chain_image_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_CHAIN_IMAGE);</div>
<div class="line"><a id="l00811" name="l00811"></a><span class="lineno">  811</span>    bootrom_release_lock(BOOTROM_LOCK_ENABLE);</div>
<div class="line"><a id="l00812" name="l00812"></a><span class="lineno">  812</span>    <span class="keywordtype">int</span> rc = func(workarea_base, workarea_size, region_base, region_size);</div>
<div class="line"><a id="l00813" name="l00813"></a><span class="lineno">  813</span>    bootrom_acquire_lock_blocking(BOOTROM_LOCK_ENABLE);</div>
<div class="line"><a id="l00814" name="l00814"></a><span class="lineno">  814</span>    <span class="keywordflow">return</span> rc;</div>
<div class="line"><a id="l00815" name="l00815"></a><span class="lineno">  815</span>}</div>
<div class="line"><a id="l00816" name="l00816"></a><span class="lineno">  816</span> </div>
<div class="line"><a id="l00817" name="l00817"></a><span class="lineno">  817</span><span class="comment">// todo SECURE only</span></div>
<div class="line"><a id="l00843" name="l00843"></a><span class="lineno">  843</span><span class="comment"></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> rom_explicit_buy(uint8_t *buffer, uint32_t buffer_size) {</div>
<div class="line"><a id="l00844" name="l00844"></a><span class="lineno">  844</span>    rom_explicit_buy_fn func = (rom_explicit_buy_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_EXPLICIT_BUY);</div>
<div class="line"><a id="l00845" name="l00845"></a><span class="lineno">  845</span>    <span class="keywordflow">return</span> func(buffer, buffer_size);</div>
<div class="line"><a id="l00846" name="l00846"></a><span class="lineno">  846</span>}</div>
<div class="line"><a id="l00847" name="l00847"></a><span class="lineno">  847</span> </div>
<div class="line"><a id="l00848" name="l00848"></a><span class="lineno">  848</span><span class="preprocessor">#ifndef __riscv</span></div>
<div class="line"><a id="l00863" name="l00863"></a><span class="lineno">  863</span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> rom_set_ns_api_permission(uint ns_api_num, <span class="keywordtype">bool</span> allowed) {</div>
<div class="line"><a id="l00864" name="l00864"></a><span class="lineno">  864</span>    rom_set_ns_api_permission_fn func = (rom_set_ns_api_permission_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_SET_NS_API_PERMISSION);</div>
<div class="line"><a id="l00865" name="l00865"></a><span class="lineno">  865</span>    <span class="keywordflow">return</span> func(ns_api_num, allowed);</div>
<div class="line"><a id="l00866" name="l00866"></a><span class="lineno">  866</span>}</div>
<div class="line"><a id="l00867" name="l00867"></a><span class="lineno">  867</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00868" name="l00868"></a><span class="lineno">  868</span> </div>
<div class="line"><a id="l00869" name="l00869"></a><span class="lineno">  869</span><span class="comment">// todo SECURE only</span></div>
<div class="line"><a id="l00889" name="l00889"></a><span class="lineno">  889</span><span class="comment"></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span>* rom_validate_ns_buffer(<span class="keyword">const</span> <span class="keywordtype">void</span> *addr, uint32_t size, uint32_t write, uint32_t *ok) {</div>
<div class="line"><a id="l00890" name="l00890"></a><span class="lineno">  890</span>    rom_validate_ns_buffer_fn func = (rom_validate_ns_buffer_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_VALIDATE_NS_BUFFER);</div>
<div class="line"><a id="l00891" name="l00891"></a><span class="lineno">  891</span>    <span class="keywordflow">return</span> func(addr, size, write, ok);</div>
<div class="line"><a id="l00892" name="l00892"></a><span class="lineno">  892</span>}</div>
<div class="line"><a id="l00893" name="l00893"></a><span class="lineno">  893</span> </div>
<div class="line"><a id="l00908" name="l00908"></a><span class="lineno">  908</span><span class="keyword">static</span> <span class="keyword">inline</span> intptr_t rom_set_rom_callback(uint callback_num, bootrom_api_callback_generic_t funcptr) {</div>
<div class="line"><a id="l00909" name="l00909"></a><span class="lineno">  909</span>    rom_set_rom_callback_fn func = (rom_set_rom_callback_fn) <a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_SET_ROM_CALLBACK);</div>
<div class="line"><a id="l00910" name="l00910"></a><span class="lineno">  910</span>    <span class="keywordflow">return</span> func(callback_num, funcptr);</div>
<div class="line"><a id="l00911" name="l00911"></a><span class="lineno">  911</span>}</div>
<div class="line"><a id="l00912" name="l00912"></a><span class="lineno">  912</span> </div>
<div class="line"><a id="l00913" name="l00913"></a><span class="lineno">  913</span><span class="preprocessor">#define BOOT_TYPE_NORMAL     0</span></div>
<div class="line"><a id="l00914" name="l00914"></a><span class="lineno">  914</span><span class="preprocessor">#define BOOT_TYPE_BOOTSEL    2</span></div>
<div class="line"><a id="l00915" name="l00915"></a><span class="lineno">  915</span><span class="preprocessor">#define BOOT_TYPE_RAM_IMAGE  3</span></div>
<div class="line"><a id="l00916" name="l00916"></a><span class="lineno">  916</span><span class="preprocessor">#define BOOT_TYPE_FLASH_UPDATE 4</span></div>
<div class="line"><a id="l00917" name="l00917"></a><span class="lineno">  917</span> </div>
<div class="line"><a id="l00918" name="l00918"></a><span class="lineno">  918</span><span class="comment">// values 8-15 are secure only</span></div>
<div class="line"><a id="l00919" name="l00919"></a><span class="lineno">  919</span><span class="preprocessor">#define BOOT_TYPE_PC_SP      0xd</span></div>
<div class="line"><a id="l00920" name="l00920"></a><span class="lineno">  920</span> </div>
<div class="line"><a id="l00921" name="l00921"></a><span class="lineno">  921</span><span class="comment">// ORed in if a bootloader chained into the image</span></div>
<div class="line"><a id="l00922" name="l00922"></a><span class="lineno">  922</span><span class="preprocessor">#define BOOT_TYPE_CHAINED_FLAG 0x80</span></div>
<div class="line"><a id="l00923" name="l00923"></a><span class="lineno">  923</span> </div>
<div class="line"><a id="l00956" name="l00956"></a><span class="lineno">  956</span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> rom_get_sys_info(uint32_t *out_buffer, uint32_t out_buffer_word_size, uint32_t flags) {</div>
<div class="line"><a id="l00957" name="l00957"></a><span class="lineno">  957</span>    rom_get_sys_info_fn func = (rom_get_sys_info_fn)<a class="code hl_function" href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a>(ROM_FUNC_GET_SYS_INFO);</div>
<div class="line"><a id="l00958" name="l00958"></a><span class="lineno">  958</span>    <span class="keywordflow">return</span> func(out_buffer, out_buffer_word_size, flags);</div>
<div class="line"><a id="l00959" name="l00959"></a><span class="lineno">  959</span>}</div>
<div class="line"><a id="l00960" name="l00960"></a><span class="lineno">  960</span> </div>
<div class="line"><a id="l00961" name="l00961"></a><span class="lineno">  961</span><span class="keyword">typedef</span> <span class="keyword">struct </span>{</div>
<div class="line"><a id="l00962" name="l00962"></a><span class="lineno">  962</span>    <span class="keyword">union </span>{</div>
<div class="line"><a id="l00963" name="l00963"></a><span class="lineno">  963</span>        <span class="keyword">struct </span>__packed {</div>
<div class="line"><a id="l00964" name="l00964"></a><span class="lineno">  964</span>            int8_t diagnostic_partition_index; <span class="comment">// used BOOT_PARTITION constants</span></div>
<div class="line"><a id="l00965" name="l00965"></a><span class="lineno">  965</span>            uint8_t boot_type;</div>
<div class="line"><a id="l00966" name="l00966"></a><span class="lineno">  966</span>            int8_t partition;</div>
<div class="line"><a id="l00967" name="l00967"></a><span class="lineno">  967</span>            uint8_t tbyb_and_update_info;</div>
<div class="line"><a id="l00968" name="l00968"></a><span class="lineno">  968</span>        };</div>
<div class="line"><a id="l00969" name="l00969"></a><span class="lineno">  969</span>        uint32_t boot_word;</div>
<div class="line"><a id="l00970" name="l00970"></a><span class="lineno">  970</span>    };</div>
<div class="line"><a id="l00971" name="l00971"></a><span class="lineno">  971</span>    uint32_t boot_diagnostic;</div>
<div class="line"><a id="l00972" name="l00972"></a><span class="lineno">  972</span>    uint32_t reboot_params[2];</div>
<div class="line"><a id="l00973" name="l00973"></a><span class="lineno">  973</span>} boot_info_t;</div>
<div class="line"><a id="l00974" name="l00974"></a><span class="lineno">  974</span> </div>
<div class="line"><a id="l00975" name="l00975"></a><span class="lineno">  975</span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> rom_get_boot_info(boot_info_t *info) {</div>
<div class="line"><a id="l00976" name="l00976"></a><span class="lineno">  976</span>    uint32_t result[5];</div>
<div class="line"><a id="l00977" name="l00977"></a><span class="lineno">  977</span>    <span class="keywordtype">int</span> words_returned = rom_get_sys_info(result, 5, SYS_INFO_BOOT_INFO);</div>
<div class="line"><a id="l00978" name="l00978"></a><span class="lineno">  978</span>    <span class="keywordflow">if</span> (words_returned == (<span class="keyword">sizeof</span>(result)/<span class="keyword">sizeof</span>(result[0])) &amp;&amp; result[0] == SYS_INFO_BOOT_INFO) {</div>
<div class="line"><a id="l00979" name="l00979"></a><span class="lineno">  979</span>        memcpy(info, &amp;result[1], <span class="keyword">sizeof</span>(boot_info_t));</div>
<div class="line"><a id="l00980" name="l00980"></a><span class="lineno">  980</span>        <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a id="l00981" name="l00981"></a><span class="lineno">  981</span>    } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00982" name="l00982"></a><span class="lineno">  982</span>        <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a id="l00983" name="l00983"></a><span class="lineno">  983</span>    }</div>
<div class="line"><a id="l00984" name="l00984"></a><span class="lineno">  984</span>}</div>
<div class="line"><a id="l00985" name="l00985"></a><span class="lineno">  985</span> </div>
<div class="line"><a id="l00986" name="l00986"></a><span class="lineno">  986</span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> rom_get_last_boot_type_with_chained_flag(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00987" name="l00987"></a><span class="lineno">  987</span>    uint32_t result[5];</div>
<div class="line"><a id="l00988" name="l00988"></a><span class="lineno">  988</span>    <span class="keywordtype">int</span> words_returned = rom_get_sys_info(result, 5, SYS_INFO_BOOT_INFO);</div>
<div class="line"><a id="l00989" name="l00989"></a><span class="lineno">  989</span>    <span class="keywordflow">if</span> (words_returned == <a class="code hl_define" href="group__pico__platform.html#ga29022c0c92a05cf88ca5046c59d6f629">count_of</a>(result) &amp;&amp; result[0] == SYS_INFO_BOOT_INFO) {</div>
<div class="line"><a id="l00990" name="l00990"></a><span class="lineno">  990</span>        <span class="comment">// todo use struct</span></div>
<div class="line"><a id="l00991" name="l00991"></a><span class="lineno">  991</span>        <span class="keywordflow">return</span> (<span class="keywordtype">int</span>)((result[1] &amp; 0xff00u) &gt;&gt; 8);</div>
<div class="line"><a id="l00992" name="l00992"></a><span class="lineno">  992</span>    } <span class="keywordflow">else</span> {</div>
<div class="line"><a id="l00993" name="l00993"></a><span class="lineno">  993</span>        <span class="keywordflow">return</span> <a class="code hl_enumvalue" href="group__pico__base.html#ggaddcb20bc9a61ceff479aa87369a862aaacf8e80b0efb54177bb4c4e6e7ed5141c">PICO_ERROR_INVALID_DATA</a>;</div>
<div class="line"><a id="l00994" name="l00994"></a><span class="lineno">  994</span>    }</div>
<div class="line"><a id="l00995" name="l00995"></a><span class="lineno">  995</span>}</div>
<div class="line"><a id="l00996" name="l00996"></a><span class="lineno">  996</span> </div>
<div class="line"><a id="l00997" name="l00997"></a><span class="lineno">  997</span><span class="comment">// BOOT_TYPE_NORMAL       0x0</span></div>
<div class="line"><a id="l00998" name="l00998"></a><span class="lineno">  998</span><span class="comment">// BOOT_TYPE_BOOTSEL      0x2</span></div>
<div class="line"><a id="l00999" name="l00999"></a><span class="lineno">  999</span><span class="comment">// BOOT_TYPE_RAM_IMAGE    0x3</span></div>
<div class="line"><a id="l01000" name="l01000"></a><span class="lineno"> 1000</span><span class="comment">// BOOT_TYPE_FLASH_UPDATE 0x4</span></div>
<div class="line"><a id="l01001" name="l01001"></a><span class="lineno"> 1001</span><span class="comment">// BOOT_TYPE_PC_SP        0xd</span></div>
<div class="line"><a id="l01002" name="l01002"></a><span class="lineno"> 1002</span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> rom_get_last_boot_type(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l01003" name="l01003"></a><span class="lineno"> 1003</span>    <span class="keywordtype">int</span> rc = rom_get_last_boot_type_with_chained_flag();</div>
<div class="line"><a id="l01004" name="l01004"></a><span class="lineno"> 1004</span>    <span class="keywordflow">if</span> (rc &gt;= 0) rc &amp;= ~BOOT_TYPE_CHAINED_FLAG;</div>
<div class="line"><a id="l01005" name="l01005"></a><span class="lineno"> 1005</span>    <span class="keywordflow">return</span> rc;</div>
<div class="line"><a id="l01006" name="l01006"></a><span class="lineno"> 1006</span>}</div>
<div class="line"><a id="l01007" name="l01007"></a><span class="lineno"> 1007</span> </div>
<div class="line"><a id="l01022" name="l01022"></a><span class="lineno"> 1022</span><span class="keywordtype">int</span> rom_add_flash_runtime_partition(uint32_t start_offset, uint32_t size, uint32_t permissions);</div>
<div class="line"><a id="l01023" name="l01023"></a><span class="lineno"> 1023</span> </div>
<div class="line"><a id="l01024" name="l01024"></a><span class="lineno"> 1024</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l01025" name="l01025"></a><span class="lineno"> 1025</span> </div>
<div class="line"><a id="l01026" name="l01026"></a><span class="lineno"> 1026</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l01027" name="l01027"></a><span class="lineno"> 1027</span>}</div>
<div class="line"><a id="l01028" name="l01028"></a><span class="lineno"> 1028</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l01029" name="l01029"></a><span class="lineno"> 1029</span> </div>
<div class="line"><a id="l01030" name="l01030"></a><span class="lineno"> 1030</span><span class="preprocessor">#endif </span><span class="comment">// !__ASSEMBLER__</span></div>
<div class="line"><a id="l01031" name="l01031"></a><span class="lineno"> 1031</span><span class="preprocessor">#endif</span></div>
<div class="ttc" id="agroup__pico__base_html_ggaddcb20bc9a61ceff479aa87369a862aaacf8e80b0efb54177bb4c4e6e7ed5141c"><div class="ttname"><a href="group__pico__base.html#ggaddcb20bc9a61ceff479aa87369a862aaacf8e80b0efb54177bb4c4e6e7ed5141c">PICO_ERROR_INVALID_DATA</a></div><div class="ttdeci">@ PICO_ERROR_INVALID_DATA</div><div class="ttdoc">A data structure failed to validate.</div><div class="ttdef"><b>Definition:</b> error.h:40</div></div>
<div class="ttc" id="agroup__pico__bootrom_html_ga1bbe1c1df02daaa7b68a0c95fb9dc545"><div class="ttname"><a href="group__pico__bootrom.html#ga1bbe1c1df02daaa7b68a0c95fb9dc545">rom_reset_usb_boot</a></div><div class="ttdeci">void rom_reset_usb_boot(uint32_t usb_activity_gpio_pin_mask, uint32_t disable_interface_mask)</div><div class="ttdoc">Reboot the device into BOOTSEL mode.</div><div class="ttdef"><b>Definition:</b> bootrom.c:43</div></div>
<div class="ttc" id="agroup__pico__bootrom_html_ga2b6dcf9d9c60d54a222f7c259c76b4b4"><div class="ttname"><a href="group__pico__bootrom.html#ga2b6dcf9d9c60d54a222f7c259c76b4b4">rom_table_code</a></div><div class="ttdeci">static uint32_t rom_table_code(uint8_t c1, uint8_t c2)</div><div class="ttdoc">Return a bootrom lookup code based on two ASCII characters.</div><div class="ttdef"><b>Definition:</b> bootrom.h:119</div></div>
<div class="ttc" id="agroup__pico__bootrom_html_ga31965209f0ddaeaecaeb3c516abda04d"><div class="ttname"><a href="group__pico__bootrom.html#ga31965209f0ddaeaecaeb3c516abda04d">rom_funcs_lookup</a></div><div class="ttdeci">bool rom_funcs_lookup(uint32_t *table, unsigned int count)</div><div class="ttdoc">Helper function to lookup the addresses of multiple bootrom functions.</div><div class="ttdef"><b>Definition:</b> bootrom.c:33</div></div>
<div class="ttc" id="agroup__pico__bootrom_html_ga472decf755ee1f64afdf14a90e6c8807"><div class="ttname"><a href="group__pico__bootrom.html#ga472decf755ee1f64afdf14a90e6c8807">rom_flash_exit_xip</a></div><div class="ttdeci">static void rom_flash_exit_xip()</div><div class="ttdoc">Return the QSPI device from its XIP state to a serial command state.</div><div class="ttdef"><b>Definition:</b> bootrom.h:307</div></div>
<div class="ttc" id="agroup__pico__bootrom_html_ga5b3c93cbab0054e9938f2aca7261a73e"><div class="ttname"><a href="group__pico__bootrom.html#ga5b3c93cbab0054e9938f2aca7261a73e">ROM_TABLE_CODE</a></div><div class="ttdeci">#define ROM_TABLE_CODE(c1, c2)</div><div class="ttdoc">Return a bootrom lookup code based on two ASCII characters.</div><div class="ttdef"><b>Definition:</b> bootrom_constants.h:157</div></div>
<div class="ttc" id="agroup__pico__bootrom_html_ga7fd2af8eea3dbd7bc76ed3306186ccef"><div class="ttname"><a href="group__pico__bootrom.html#ga7fd2af8eea3dbd7bc76ed3306186ccef">rom_flash_range_program</a></div><div class="ttdeci">static void rom_flash_range_program(uint32_t addr, const uint8_t *data, size_t count)</div><div class="ttdoc">Program bytes in flash.</div><div class="ttdef"><b>Definition:</b> bootrom.h:368</div></div>
<div class="ttc" id="agroup__pico__bootrom_html_ga8f4e326502015aa4f4624251df366268"><div class="ttname"><a href="group__pico__bootrom.html#ga8f4e326502015aa4f4624251df366268">rom_func_lookup_inline</a></div><div class="ttdeci">static __force_inline void * rom_func_lookup_inline(uint32_t code)</div><div class="ttdoc">Lookup a bootrom function by code. This method is forcibly inlined into the caller for FLASH/RAM sens...</div><div class="ttdef"><b>Definition:</b> bootrom.h:217</div></div>
<div class="ttc" id="agroup__pico__bootrom_html_gaa089fab5e976fea3fd88fecb44863ffc"><div class="ttname"><a href="group__pico__bootrom.html#gaa089fab5e976fea3fd88fecb44863ffc">rom_connect_internal_flash</a></div><div class="ttdeci">static void rom_connect_internal_flash()</div><div class="ttdoc">Connect the SSI/QMI to the QSPI pads.</div><div class="ttdef"><b>Definition:</b> bootrom.h:276</div></div>
<div class="ttc" id="agroup__pico__bootrom_html_gaaaf61234f389da6444b6479f29616d7d"><div class="ttname"><a href="group__pico__bootrom.html#gaaaf61234f389da6444b6479f29616d7d">rom_func_lookup</a></div><div class="ttdeci">void * rom_func_lookup(uint32_t code)</div><div class="ttdoc">Lookup a bootrom function by its code.</div><div class="ttdef"><b>Definition:</b> bootrom.c:13</div></div>
<div class="ttc" id="agroup__pico__bootrom_html_gacd6b37e87ff97264edba6c6349e52f72"><div class="ttname"><a href="group__pico__bootrom.html#gacd6b37e87ff97264edba6c6349e52f72">rom_flash_flush_cache</a></div><div class="ttdeci">static void rom_flash_flush_cache()</div><div class="ttdoc">Flush the XIP cache.</div><div class="ttdef"><b>Definition:</b> bootrom.h:390</div></div>
<div class="ttc" id="agroup__pico__bootrom_html_gad2a854a04f7007e9e5efa67fe8887cd7"><div class="ttname"><a href="group__pico__bootrom.html#gad2a854a04f7007e9e5efa67fe8887cd7">rom_flash_range_erase</a></div><div class="ttdeci">static void rom_flash_range_erase(uint32_t addr, size_t count, uint32_t block_size, uint8_t block_cmd)</div><div class="ttdoc">Erase bytes in flash.</div><div class="ttdef"><b>Definition:</b> bootrom.h:343</div></div>
<div class="ttc" id="agroup__pico__bootrom_html_gad3e66e7bcbf0448a0a63cf37dfb4b53c"><div class="ttname"><a href="group__pico__bootrom.html#gad3e66e7bcbf0448a0a63cf37dfb4b53c">rom_data_lookup</a></div><div class="ttdeci">void * rom_data_lookup(uint32_t code)</div><div class="ttdoc">Lookup a bootrom data address by its code.</div><div class="ttdef"><b>Definition:</b> bootrom.c:20</div></div>
<div class="ttc" id="agroup__pico__bootrom_html_gae2af7b462bd0a7e9d0fc0a5fc1ce909e"><div class="ttname"><a href="group__pico__bootrom.html#gae2af7b462bd0a7e9d0fc0a5fc1ce909e">rom_flash_enter_cmd_xip</a></div><div class="ttdeci">static void rom_flash_enter_cmd_xip()</div><div class="ttdoc">Configure the SSI/QMI with a standard command.</div><div class="ttdef"><b>Definition:</b> bootrom.h:406</div></div>
<div class="ttc" id="agroup__pico__platform_html_ga23eadd8d1642fb8fe4600708c36e116a"><div class="ttname"><a href="group__pico__platform.html#ga23eadd8d1642fb8fe4600708c36e116a">__force_inline</a></div><div class="ttdeci">#define __force_inline</div><div class="ttdoc">Attribute to force inlining of a function regardless of optimization level.</div><div class="ttdef"><b>Definition:</b> compiler.h:125</div></div>
<div class="ttc" id="agroup__pico__platform_html_ga29022c0c92a05cf88ca5046c59d6f629"><div class="ttname"><a href="group__pico__platform.html#ga29022c0c92a05cf88ca5046c59d6f629">count_of</a></div><div class="ttdeci">#define count_of(a)</div><div class="ttdoc">Macro to determine the number of elements in an array.</div><div class="ttdef"><b>Definition:</b> compiler.h:132</div></div>
<div class="ttc" id="agroup__pico__platform_html_ga66edd7569f5a42b0a2da43a5926cf064"><div class="ttname"><a href="group__pico__platform.html#ga66edd7569f5a42b0a2da43a5926cf064">pico_processor_state_is_nonsecure</a></div><div class="ttdeci">static __force_inline bool pico_processor_state_is_nonsecure(void)</div><div class="ttdoc">Return true if executing in the NonSecure state (Arm-only)</div><div class="ttdef"><b>Definition:</b> platform.h:188</div></div>
<div class="ttc" id="apico_8h_html"><div class="ttname"><a href="pico_8h.html">pico.h</a></div></div>
<div class="ttc" id="astructcflash__flags_html"><div class="ttname"><a href="structcflash__flags.html">cflash_flags</a></div><div class="ttdef"><b>Definition:</b> bootrom_constants.h:305</div></div>
<div class="ttc" id="astructotp__cmd_html"><div class="ttname"><a href="structotp__cmd.html">otp_cmd</a></div><div class="ttdef"><b>Definition:</b> bootrom_constants.h:273</div></div>
<div class="ttc" id="astructresident__partition__t_html"><div class="ttname"><a href="structresident__partition__t.html">resident_partition_t</a></div><div class="ttdef"><b>Definition:</b> bootrom_constants.h:262</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->

	<script src="main.js"></script>
</body>
</html>